﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DVDFilmoteka.Sorting
{
    public enum ESorters { ABECEDNI_ORIGINAL, ABECEDNI_CESKY, ZANR, KOMPRESE, ZADNY, DATETIME, HODNOCENI };

    public class SorterStrategy
    {
        private static Dictionary<ESorters, ISorter> sorterPool = null;
        private static ESorters actSorter;

        public static ISorter getSorter()
        {
            if (sorterPool == null)
            {
                setSorter(ESorters.ABECEDNI_CESKY);
            }

            return sorterPool[actSorter];
        }

        public static void setSorter(ESorters newSorter)
        {
            if (sorterPool == null)
            {
                sorterPool = new Dictionary<ESorters, ISorter>();

                ISorter sorter = null;
                
                sorter = new AbecedniCeskySorter();
                sorterPool.Add(ESorters.ABECEDNI_CESKY, sorter);

                sorter = new AbecedniOriginalSorter();
                sorterPool.Add(ESorters.ABECEDNI_ORIGINAL, sorter);

                sorter = new KompreseSorter();
                sorterPool.Add(ESorters.KOMPRESE, sorter);

                sorter = new NoneSorter();
                sorterPool.Add(ESorters.ZADNY, sorter);

                sorter = new ZanrSorter();
                sorterPool.Add(ESorters.ZANR, sorter);

                sorter = new DateSorter();
                sorterPool.Add(ESorters.DATETIME, sorter);

                sorter = new HodnoceniSorter();
                sorterPool.Add(ESorters.HODNOCENI, sorter);
            }

            actSorter = newSorter;
        }
    }
}
